package com.sunjob.mrogeteway.filter;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.ToString;
import org.springframework.cloud.gateway.filter.GatewayFilter;
import org.springframework.cloud.gateway.filter.factory.AbstractGatewayFilterFactory;
import org.springframework.stereotype.Component;

/**
 * Created by IntelliJ IDEA.
 *
 * @Author : Wangzurong
 * @create 2022-08-04 23:12
 */
@Component
public class MROQpsPartLimiterGatewayFilterFactory extends AbstractGatewayFilterFactory<MROQpsPartLimiterGatewayFilterFactory.MROQpsConfig> {

public MROQpsPartLimiterGatewayFilterFactory(){
    super(MROQpsConfig.class);
}
    @Override
    public GatewayFilter apply(MROQpsConfig config) {
        return new MROQpsPartLimiterFilter(config.getQpsVal(),config.getQpsSplit());
    }

    @Data
    @ToString
    @AllArgsConstructor
    public static class MROQpsConfig{
        private int qpsVal;
        private int qpsSplit;
    }
}
